<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">{$day}进场费用申请明细</h2>
</div>
<!-- 标题 -->
<form class="form-inline">
    <table class="table-bordered table text-left" border="1">
        <tr>
            <td><label for="" class="form-label">主题<span class="colorRed">*</span>：</label></td>
            <td><input type="text" class="form-control" name="title" id="title" value="{:isset($data)?$data.title:''}"></td>
        </tr>
        <tr>
            <td style="min-width: 180px;width: 180px">
                <label for="">经销商<span class="colorRed">*</span>：</label>
            </td>
            <td colspan="5">
                <div class="col-xs-4">
                    <div class="input-group" id="jxs_input" {if isset($data)}style="display: none;"{/if}>
                        <input type="text" placeholder="请输入关键字或空格查询" class="form-control inputremindPeple" id="jxs_id"
                               name="jxs_id" value="{:isset($data)?$data.jxs_id:''}">
                        <div class="input-group-btn">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                            </ul>
                        </div>
                    </div>
                    <div id="jxs_queding" class="selectedOnlyOne" {if !isset($data)}style="display:none;"{/if}>
                        {if isset($data)}
                        <span class="inin" data-id="{$data.jxs_id}">{$data.jxs_title}</span>
                        <span class="close">×</span>
                        {else}
                        <span class="inin"></span>
                        <span class="close">×</span>
                        {/if}
                    </div>
                </div>
                <div class="col-xs-2">
                    <button class="btn btn-primary" id="select">选择</button>
                </div>
            </td>
        </tr>
        <tr style="display: none">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <div class="contact-box">
        <button class="btn btn-success" type="button" id="addData">添加数据</button>
        (至少添加一条费用明细) <span class="colorRed">温馨提示：1）一个活动不要分开申请，否则会影响该活动的ROI;2)多个活动不要放在同一个申请中申请，否则会影响后续的反馈，核销。谢谢！</span>
    </div>
    <div class="row no-padding">
        <table class="table row-margin-top table-bordered text-center bud_hei" id="mingxi">
            <thead>
            <tr class="info">
                <td rowspan="2">
                    操作
                </td>
                <td rowspan="2">序号</td>
                <td rowspan="2">明细编号</td>
                <td rowspan="2">系统名称</td>
                <td rowspan="2">负责人</td>
                <td rowspan="2">网点名称</td>
                <td rowspan="2">系统网点数</td>
                <td rowspan="2">申请进店数</td>
                <td rowspan="2">网点详细地址</td>
                <td rowspan="2">网点类型</td>
                <td rowspan="2">产品系列</td>
                <td rowspan="2">进场月份</td>
                <td rowspan="2">预计核销时间</td>
                <td rowspan="2">单店销量(万元/月)</td>
                <td rowspan="2">已进条码产品名称</td>
                <td colspan="8">申请进场产品</td>
                <td colspan="9">本次申请进场费用</td>
                <td rowspan="2">备注</td>
            </tr>
            <tr class="info">
                <td>本次申请进场产品</td>
                <td>标准出厂价</td>
                <td>经销商原供货价</td>
                <td>加价率</td>
                <td>零售商供货价</td>
                <td>加价率</td>
                <td>公司建议零售价</td>
                <td>加价率</td>
                <td>三级费用科目</td>
                <td>费用支付方式</td>
                <td>未税费用金额(元)</td>
                <td>是否增值税(可抵扣)</td>
                <td>税率</td>
                <td>含税费用金额(元)</td>
                <td>实际投入费用(元)</td>
                <td>费用计入部门</td>
                <td>费用计入方案</td>
            </tr>
            </thead>
            <tbody>{if isset($str)}{$str}{/if}
            </tbody>
        </table>
         {if isset($data)}
        {if $data.status==2}
          <div class="" style="margin:20px 10px 20px 20px;">
         <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
            {volist name="logs" id="l"}
          <tr>
              <td>{$l.USERNAME} 审批动作：{$l.MEMO}；审批意见：{if $l.COMMENTS}{$l.COMMENTS}{else/}无{/if}(审批时间：{$l.ACTIONTIME})</td>
          </tr>
          
          {/volist}
      </table>
      </div>
      {/if}{/if}
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            {if isset($attach)}
            <ul class="list-group">
                {volist name="attach" id="row"}
                <li class="list-group-item">
                    <a class="badge badge-primary removeIt" data-id="{$row.id}">移除</a>
                    <a href="{$row.path}" target="_blank">{$row.file_name}</a></li>
                {/volist}
            </ul>
            {/if}
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list"></div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach">
                <input type="hidden" name="remove" id="remove">
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
        <div class="row text-center no-padding">
            {if isset($data)}
        {if $data.status==2}
                <input type="hidden" name="aid" value="{$data.id}"/>
                 <input type="hidden" id="nodeKey" name="nodeKey"/>
                  <input type="hidden" id="selectId" name="selectId"/>
                  <input type="hidden" id="selectName" name="selectName"/>
                    {volist name="btn.nextNodes" id="b"}
                      {if $b.nodeName=='结束'}
                      <input type="button" class="btn-danger btn" onclick="zuofei('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="点此作废"/>
                      {else/}
                      <input type="button" class="btn-info btn" onclick="baocun('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="保存并提交工作流"/>
                      {/if}
                    {/volist}
                {else/}
            <input type="button" class="btn btn-success save" value="保存为草稿" id="save1">
            <input type="button" class="btn btn-success save" value="保存并提交工作流" id="save2">
            <input type="button" class="btn btn-info" value="保存为模版" id="save3">
            {/if}
            {else/}
             <input type="button" class="btn btn-success save" value="保存为草稿" id="save1">
            <input type="button" class="btn btn-success save" value="保存并提交工作流" id="save2">
            <input type="button" class="btn btn-info" value="保存为模版" id="save3">
            {/if}
            <input type="button" class="btn btn-warning" value="返回" id="fanhui">
        </div>
        <input type="hidden" name="ti_id" id="ti_id" value="{if isset($data)}{$data.id}{/if}">
    </div>
</form>

<!-- 全局js -->
{include file="Public/footer"}
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
    var link1 = '{:url("select/myjxsjson")}'
    var link2 = '{:url("Tiapply2/selectjxs")}'
    var link3 = '{:url("adddata")}'
    var link4 = '{:url("updatedata")}'
    var link5 = '{:url("index")}'
    var link6 = '{:url("delItem")}'
    var link7 = '{:url("feeList")}'
</script>
<script src="__STATIC__/layout/js/tijinchang/form.js"></script>
</body>

<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
    var upload_url = '{:url("upload/fileupload")}';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script src="__STATIC__/layout/js/upload.js"></script>
<script>
var fr={$from};
function baocun(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
  var title = $('#title').val()
        if (title == '') {
            swal('', '请填写主题', 'error')
            return false
        }

        var jxs_id = $('[name=jxs_id]').val()
        if (jxs_id == '') {
            swal('', '请选择经销商', 'error')
            return false
        }
        var list = []
        $('#mingxi tbody tr').each(function (i, o) {
            list.push($(o).data('id'))
        })
        if (list.length < 1) {
            swal('', '请添加至少一条数据', 'error')
            return false
        }
        list = list.join(',')
        var attach = $('#attach').val()
        var remove = $('#remove').val()
        var data = {}
        data.title = title
        data.jxs_id = jxs_id
        data.list = list
        data.attach = attach
        data.remove = remove
        data.ti_id = $('#ti_id').val()
            data.savetype = 3
            data.nodeKey=nodeKey
            data.selectId=selectId
            data.selectName=selectName
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('baocunchuli')}",
          data:data,// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  if(fr==1)
                                        location.href="{:url('index')}"
                                  else
                                        location.href="{:url('Workflowdb/index')}"
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
}
 function zuofei(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('zuofeichuli')}",
          data:{aid:$("[name='aid']").val(),nodeKey:nodeKey,selectId:selectId,selectName:selectName},// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
           //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('index')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }         
          }
        });
}
 $('#fanhui').on('click',function () {
            if(fr==1)
                                        location.href="{:url('index')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
        })
</script>
</html>